#include <cstdio>
#include <algorithm>
using namespace std;
unsigned int BKDRHash(char *s){
    unsigned int seed=131;
    unsigned int hash=0;
    while(*s){
        printf("%c\n",*s);
        hash=hash*seed+(*s++);
        printf("%u\n",hash);
    }
    return (hash & 0x7FFFFFFF);
}
int main(void){
    char a[]="abc";
    BKDRHash(a);
    char b[]="abd";
    BKDRHash(b);
    return 0;
}